<?php
App::uses('Controller', 'Controller');
App::uses('CakeRequest', 'Network');
App::uses('CakeResponse', 'Network');
App::uses('ComponentCollection', 'Controller');
App::uses('EmailComponent', 'Controller/Component');

// A fake controller to test against
class TestEmailController extends Controller {
    
}

class EmailComponentTest extends CakeTestCase {
    public $EmailComponent = null;
    public $Controller = null;

    public function setUp() {
        parent::setUp();
        // Setup our component and fake test controller
        $Collection = new ComponentCollection();
        $this->EmailComponent = new EmailComponent($Collection);
        $CakeRequest = new CakeRequest();
        $CakeResponse = new CakeResponse();
        $this->Controller = new TestEmailController($CakeRequest, $CakeResponse);
        $this->EmailComponent->startup($this->Controller);
        $this->EmailComponent->novoEmail();
        $this->EmailComponent->transport('Debug');
    }
    
	public function testEmailSemDestinatario() {
    	$this->setExpectedException('SocketException');
		$this->EmailComponent->assunto('E-mail de teste');
		$this->EmailComponent->ocultos(array());
		pr($this->EmailComponent->mensagem('E-mail de teste apenas'));exit;
    }

    public function testEmailEmailInvalido() {
    	$this->setExpectedException('SocketException');
		$this->EmailComponent->assunto('E-mail de teste');
		$this->EmailComponent->ocultos(array('willen.goulart'));
		pr($this->EmailComponent->mensagem('E-mail de teste apenas'));exit;
    }
    
	public function testEmail() {
		$this->EmailComponent->assunto('E-mail de teste');
		$this->EmailComponent->ocultos(array('willen.goulart@gmail.com'));
		$this->EmailComponent->mensagem('E-mail de teste apenas');
    }

    public function tearDown() {
        parent::tearDown();
        // Clean up after we're done
        unset($this->EmailComponent);
        unset($this->Controller);
    }
}

?>